import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '编码',
    align: "center",
    sorter: true,
    dataIndex: 'code'
  },
  {
    title: '名称',
    align: "center",
    sorter: true,
    dataIndex: 'name'
  },
  {
    title: '交货方式',
    align: "center",
    sorter: true,
    dataIndex: 'deliveryMethod',
    customRender: ({ text }) => {
      return text == 0 ? '供应商送货' : text == 1 ? '自提' : ''
    },
  },
  {
    title: '默认拒收处理方式',
    align: "center",
    sorter: true,
    dataIndex: 'rejectionProcessingMethod',
    customRender: ({ text }) =>  text == 0 ? '退补' : text == 1 ? '退扣' : ''
  },
  {
    title: '是否有效',
    align: "center",
    sorter: true,
    dataIndex: 'effectiveStatus',
    customRender: ({ text }) => {
      return text == 0 ? '否' : text == 1 ? '是' : ''
    },
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
  {
    title: '第三方编码',
    align: "center",
    dataIndex: 'thirdPartyCode'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编码",
    field: 'code',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "名称",
    field: 'name',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "交货方式",
    field: 'deliveryMethod',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [{ label: '自提', value: 1 }, { label: '供应商送货', value: 0 }]
    }
  },
  {
    label: "默认拒收处理方式",
    field: 'rejectionProcessingMethod',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [{ label: '退扣', value: 1 }, { label: '退补', value: 0 }]
    }
  },
  {
    label: "是否有效",
    field: 'effectiveStatus',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [{ label: '是', value: 1 }, { label: '否', value: 0 }]
    }
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [
             { required: true, message: '请输入名称!'},
      ];
 },
  },
  {
    label: '交货方式',
    field: 'deliveryMethod',
    component: 'Select',
    defaultValue: 0,
    componentProps: {
      options: [{ label: '自提', value: 1 }, { label: '供应商送货', value: 0 }],
      stringToNumber: true,
    }
  },
  {
    label: '默认拒收处理方式',
    field: 'rejectionProcessingMethod',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: [{ label: '退扣', value: 1 }, { label: '退补', value: 0 }],
      stringToNumber: true,
    }
  },
  {
    label: '是否有效',
    field: 'effectiveStatus',
    defaultValue: 1,
    component: 'JSwitch',
    componentProps: {
      options: [1, 0]
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}